import time

from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.get("https://www.baidu.com")
driver.maximize_window()
time.sleep(5)
# 登录账号后和没登陆账号页面不一样
ul = driver.find_element(By.ID, "hotsearch-content-wrapper")
li = ul.find_elements(By.CLASS_NAME, 'hotsearch-item')
for i in li:
    span = i.find_element(By.CLASS_NAME, 'title-content-title')
    print(span.text)
print('over!!')